package com.Fengxwgl.service.impl;

import com.Fengxwgl.dao.UserDao;
import com.Fengxwgl.entity.Shiming;
import com.Fengxwgl.entity.User;
import com.Fengxwgl.service.UserSer;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class UserService implements UserSer {
    @Resource
    private UserDao userDao;

    @Override
    public Integer phone(String phone) {
        return userDao.phone(phone);
    }

    @Override
    public Integer zhuche(String phone, String password) {
        Map map=new HashMap();
        map.put("phone",phone);
        map.put("password",password);
        map.put("nicheng","侠客"+(int)((Math.random() * 9 + 1) * 100));
        return userDao.zhuche(map);
    }

    @Override
    public Map denglu(String phone, String password) {
        Map map=new HashMap();
        map.put("phone",phone);
        User denglu = userDao.denglu(map);
        Map map1=new HashMap();
        if(denglu==null){
            map1.put("denglu",0);
            map1.put("user",null);
            return map1;}
        String password1 = denglu.getPassword();
        if(password==password1||password.equals(password1)){
            map1.put("denglu",1);
            map1.put("user",denglu);
        }else{
            map1.put("denglu",0);
            map1.put("user",null);
        }
        return map1;
    }

    @Override
    public Integer shiming(Shiming shiming) {
        Integer shiming1 = userDao.shiming(shiming);
        if(shiming1==1){

        }
        return shiming1;
    }
}
